﻿using HRMSystemShi.DAL;
using HRMSystemShi.Model;
using NPOI.SS.UserModel;

namespace HRMsystemShi._2025
{
    public partial class FormCheckSalarySheet : Form
    {
        public FormCheckSalarySheet()
        {
            InitializeComponent();
        }
        private void  FormCheckSalarySheet_Load(object sender, EventArgs e)
        {
            dataGridViewSalarySheet.DataSource = SalarySheetService.GetSalarySheetTable();
        }

        private void dataGridViewSalarySheet_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridViewSalarySheet.SelectedRows.Count > 0)
            {
                int year = (int)dataGridViewSalarySheet.SelectedRows[0].Cells[0].Value;
                int month = (int)dataGridViewSalarySheet.SelectedRows[0].Cells[1].Value;
                string? depart = dataGridViewSalarySheet.SelectedRows[0].Cells[2].Value.ToString();
                Guid deptnameId =DepartmentService.GetDepartmentId(depart!);
                SalarySheet salarySheet = SalarySheetService.GetSalarySheet(year, month, deptnameId);
                dataGridViewDetails.DataSource =SalarySheetService.GetSalarySheetItem(salarySheet);
                dataGridViewDetails.ReadOnly = true;
            }
        }
    }
}
